//
//  ZCXUserDetialTableViewCell.m
//  LoveOfPet
//
//  Created by dllo on 15/11/16.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "ZCXUserDetialTableViewCell.h"
#import "ZCXUserDetialView.h"

#define HEIGHT  [[UIScreen mainScreen]bounds].size.height / 667
#define WIDTH   [[UIScreen mainScreen]bounds].size.width / 375
@interface ZCXUserDetialTableViewCell ()<UIWebViewDelegate>
@property (nonatomic, retain) UIWebView *webView;
@property (nonatomic, retain) UIActivityIndicatorView *activity;
@property (nonatomic, retain) ZCXUserDetialView *view;
@end

@implementation ZCXUserDetialTableViewCell
- (void)dealloc{
    [_webView release];
    [_userDetial release];
    [_view release];
    [_activity release];
    [super dealloc];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.webView = [[UIWebView alloc]init];
        _webView.scalesPageToFit = YES;
        _webView.scrollView.bounces = NO;
        _webView.scrollView.showsVerticalScrollIndicator = NO;
        _webView.delegate = self;
        [self.contentView addSubview:_webView];
        [_webView release];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    _webView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
}
- (void)setUserDetial:(ZCXUserDetial *)userDetial{
    if (_userDetial != userDetial) {
        [_userDetial release];
        _userDetial = [userDetial retain];
    }
    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:userDetial.url]];
    [_webView loadRequest:request];
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
    self.activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    self.activity.color = [UIColor grayColor];
    self.activity.center = self.center;
    [self addSubview:self.activity];
    [self.activity startAnimating];
    [self.activity setHidesWhenStopped:YES];
    [_activity release];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [self.activity stopAnimating];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
